<?php
$loader->requireOnce('includes/inPatientCore/InPatientCoreErrorCode.class.php');
$loader->requireOnce('includes/inPatientCore/InPatientCoreException.class.php');
$loader->requireOnce('includes/inPatientCore/InPatientSurgery.class.php');
$loader->requireOnce('includes/inPatientCore/InPatientEctomy.class.php');
$loader->requireOnce('ordo/InPatient.class.php');
$loader->requireOnce('ordo/SurgeryServiceGroup.class.php');



/**
 * InputServiceLoader Processor.
 * @package core.includes.inPatientCore
 * @author viethd
 * @version $Id$
 * @copyright 2009 LHV Company
 */
class InputServiceLoader {
    protected $controller;

    private $logger ;


    /**
     *
     * @param $controller controller for build ui
     */
    function __construct($controller) {
        $this->logger = LoggerManager::getLogger('core.inPatientCore.InputServiceLoader');
        $this->controller = $controller;

    }
    
    public function loadServiceSelection($ticketId) {
        $path = $this->controller->view->path;
        //get treatment result enum list
        //$surgeryServiceTypes = Utils::getEnumArrayValue(EnumerationConstant::SURGERY_CLASSIFY);
        
        $this->controller->view->path = "service_input";
        $orders =   L10nHelper::getYMDorder();
        $this->controller->assign('datePart_0', $orders[0]);
        $this->controller->assign('datePart_1', $orders[1]);
        $this->controller->assign('datePart_2', $orders[2]);        
        $this->controller->assign('ticketId', $ticketId);
        //$this->controller->assign('surgeryServiceTypes', $surgeryServiceTypes);
        
        //prepare data for rendering select surgery pop up
        $data4SelectSurgery = Celini::newORDO('SurgeryService')->getData4RenderSelectSurgeryService();
        $this->controller->assign('groupList', $data4SelectSurgery['groupList']);
        $this->controller->assign('servList', $data4SelectSurgery['servList']);
        
        $form = $this->controller->view->render('input_service.html');
        $this->controller->view->path = $path;
        return $form;
    }
    
    public function loadSurgeryServiceInputForm($ticketId, $enumSurgeryServiceCatergoryId) {
    	
    	switch ($enumSurgeryServiceCatergoryId) {
    		
    		default:
    			;
    		case SurgeryServiceGroup::SURGERY:
                 $obj = new InPatientSurgery($this->controller);
                 return $obj->loadInputForm($ticketId);   		   
    		case SurgeryServiceGroup::ECTOMY:
    			$obj = new InPatientEctomy($this->controller);
    			return $obj->loadInputForm($ticketId);   
    	}
    }
    
    
    
    public function ListOfService($surgeryServiceType) {
    	$result = array();
    	$surgeryServiceObj = Celini::newOrdo("SurgeryService");
    	$result = $surgeryServiceObj->getInServiceInfo($this->controller->_me->get_department_id(),false, null, $surgeryServiceType);
    	return $result;
    }
    
}
?>